{
  "name": "Case 60: NDA Deviation Detector",
  "nodes": [
    {
      "parameters": {
        "path": "nda-deviation-detector",
        "formTitle": "NDA Deviation Detector",
        "formDescription": "Upload vendor-signed NDA for automatic deviation analysis",
        "formFields": {
          "values": [
            {
              "fieldLabel": "Vendor-Signed NDA (PDF)",
              "fieldType": "file",
              "requiredField": true
            },
            {
              "fieldLabel": "Vendor Name",
              "fieldType": "text",
              "requiredField": true
            },
            {
              "fieldLabel": "NDA Date (YYYY-MM-DD)",
              "fieldType": "text",
              "requiredField": true
            },
            {
              "fieldLabel": "Template Version Used",
              "fieldType": "dropdown",
              "fieldOptions": {
                "values": [
                  {
                    "option": "Standard Corporate Template v2.1"
                  },
                  {
                    "option": "Standard Corporate Template v2.0"
                  },
                  {
                    "option": "Standard Corporate Template v1.9"
                  }
                ]
              },
              "requiredField": true
            }
          ]
        },
        "options": {}
      },
      "id": "form-trigger-001",
      "name": "NDA Upload Form",
      "type": "n8n-nodes-base.formTrigger",
      "typeVersion": 2.1,
      "position": [-992, -64],
      "webhookId": "nda-deviation-detector"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.cloud.llamaindex.ai/api/v1/parsing/upload",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer llx-7BWYrvPwfUhgdXbZMtaNCsr2O0h7JH4dkHjHisxcvq46bkIj"
            }
          ]
        },
        "sendBody": true,
        "contentType": "multipart-form-data",
        "bodyParameters": {
          "parameters": [
            {
              "parameterType": "formBinaryData",
              "name": "file",
              "inputDataFieldName": "Vendor-Signed_NDA__PDF_"
            }
          ]
        },
        "options": {}
      },
      "id": "upload-nda-001",
      "name": "Upload NDA",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.3,
      "position": [-816, -64]
    },
    {
      "parameters": {
        "amount": 20
      },
      "id": "wait-001",
      "name": "Wait",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [-640, -64],
      "webhookId": "wait-webhook-001"
    },
    {
      "parameters": {
        "url": "=https://api.cloud.llamaindex.ai/api/v1/parsing/job/{{ $node[\"Upload NDA\"].json[\"id\"] }}",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer llx-7BWYrvPwfUhgdXbZMtaNCsr2O0h7JH4dkHjHisxcvq46bkIj"
            }
          ]
        },
        "options": {}
      },
      "id": "check-status-001",
      "name": "Check Status",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.3,
      "position": [-496, -64]
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "conditions": [
                  {
                    "leftValue": "={{ $json.status }}",
                    "rightValue": "SUCCESS",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ]
              },
              "renameOutput": true,
              "outputKey": "SUCCESS"
            },
            {
              "conditions": {
                "conditions": [
                  {
                    "leftValue": "={{ $json.status }}",
                    "rightValue": "PENDING",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ]
              },
              "renameOutput": true,
              "outputKey": "PENDING"
            }
          ]
        },
        "options": {}
      },
      "id": "router-001",
      "name": "Router",
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.3,
      "position": [-336, -64]
    },
    {
      "parameters": {
        "url": "=https://api.cloud.llamaindex.ai/api/v1/parsing/job/{{ $node[\"Upload NDA\"].json[\"id\"] }}/result/markdown",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer llx-7BWYrvPwfUhgdXbZMtaNCsr2O0h7JH4dkHjHisxcvq46bkIj"
            }
          ]
        },
        "options": {}
      },
      "id": "get-data-001",
      "name": "Get Vendor NDA",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.3,
      "position": [-144, -144]
    },
    {
      "parameters": {
        "text": "={{ $json.markdown }}",
        "attributes": {
          "attributes": [
            {
              "name": "Section_1_Definitions",
              "description": "Extract complete text of Section 1 Definitions"
            },
            {
              "name": "Section_2_Confidentiality",
              "description": "Extract complete text of Section 2 Confidentiality Obligations"
            },
            {
              "name": "Section_3_Exclusions",
              "description": "Extract complete text of Section 3 Exclusions"
            },
            {
              "name": "Section_4_Term",
              "description": "Extract complete text of Section 4 Term and Termination, including specific durations mentioned"
            },
            {
              "name": "Section_5_License",
              "description": "Extract complete text of Section 5 No License or Warranty"
            },
            {
              "name": "Section_6_Remedies",
              "description": "Extract complete text of Section 6 Remedies"
            },
            {
              "name": "Section_7_Liability",
              "description": "Extract complete text of Section 7 Limitation of Liability, including dollar amounts"
            },
            {
              "name": "Section_8_Governing_Law",
              "description": "Extract complete text of Section 8 Governing Law and Jurisdiction, including state/jurisdiction"
            },
            {
              "name": "Section_9_General",
              "description": "Extract complete text of Section 9 General Provisions"
            },
            {
              "name": "Additional_Sections",
              "description": "Extract any additional sections beyond Section 9 that are not in standard template"
            },
            {
              "name": "Missing_Sections",
              "description": "List any expected sections that are missing or deleted"
            }
          ]
        },
        "options": {}
      },
      "id": "extract-vendor-nda-001",
      "name": "Extract Vendor NDA",
      "type": "@n8n/n8n-nodes-langchain.informationExtractor",
      "typeVersion": 1.2,
      "position": [48, -144]
    },
    {
      "parameters": {
        "jsCode": "// EMBEDDED STANDARD TEMPLATE v2.1\nconst STANDARD_TEMPLATE = {\n  Section_1_Definitions: `1. DEFINITIONS\\n1. \"Confidential Information\" means all information, whether written, oral, electronic, or visual, disclosed by Disclosing Party to Receiving Party that is marked as confidential or that a reasonable person would understand to be confidential given the nature of the information and circumstances of disclosure. This includes, without limitation, trade secrets, business plans, financial information, customer data, technical data, software, algorithms, and any other proprietary information.\\n2. \"Purpose\" means the evaluation of a potential business relationship between the parties related to [SPECIFY PURPOSE].`,\n  \n  Section_2_Confidentiality: `2. CONFIDENTIALITY OBLIGATIONS\\n1. Receiving Party agrees to hold all Confidential Information in strict confidence and not to disclose such information to any third parties without the prior written consent of Disclosing Party.\\n2. Receiving Party shall use Confidential Information solely for the Purpose and shall not use such information for any other purpose without Disclosing Party's express written authorization.\\n3. Receiving Party shall protect Confidential Information using the same degree of care it uses to protect its own confidential information, but in no event less than reasonable care.\\n4. Receiving Party shall limit access to Confidential Information to employees, contractors, and advisors who have a legitimate need to know for the Purpose and who have been informed of the confidential nature of such information.`,\n  \n  Section_4_Term: `4. TERM AND TERMINATION\\nThis Agreement shall commence on the Effective Date and continue for a period of five (5) years unless earlier terminated by either party upon thirty (30) days' written notice to the other party.\\nUpon termination or expiration of this Agreement, Receiving Party shall, at Disclosing Party's option, either return or destroy all Confidential Information and certify in writing that it has done so. The confidentiality obligations set forth herein shall survive termination for a period of three (3) years.`,\n  \n  Section_7_Liability: `7. LIMITATION OF LIABILITY\\nIN NO EVENT SHALL DISCLOSING PARTY BE LIABLE FOR ANY INDIRECT, INCIDENTAL, SPECIAL, CONSEQUENTIAL, OR PUNITIVE DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE CONFIDENTIAL INFORMATION, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. DISCLOSING PARTY'S TOTAL LIABILITY UNDER THIS AGREEMENT SHALL NOT EXCEED THE ACTUAL DIRECT DAMAGES PROVEN, UP TO A MAXIMUM OF $100,000.`,\n  \n  Section_8_Governing_Law: `8. GOVERNING LAW AND JURISDICTION\\nThis Agreement shall be governed by and construed in accordance with the laws of the State of Delaware, without regard to its conflict of laws principles.`\n};\n\n// CRITICAL CLAUSES WITH RISK WEIGHTS\nconst CRITICAL_CLAUSES = {\n  Section_2_Confidentiality: { priority: 'CRITICAL', weight: 40 },\n  Section_4_Term: { priority: 'HIGH', weight: 25 },\n  Section_7_Liability: { priority: 'HIGH', weight: 25 },\n  Section_8_Governing_Law: { priority: 'MEDIUM', weight: 15 },\n  Section_1_Definitions: { priority: 'MEDIUM', weight: 15 },\n  Section_6_Remedies: { priority: 'MEDIUM', weight: 15 },\n  Section_3_Exclusions: { priority: 'LOW', weight: 5 },\n  Section_5_License: { priority: 'LOW', weight: 5 },\n  Section_9_General: { priority: 'LOW', weight: 5 }\n};\n\n// Get vendor NDA data\nconst vendorNDA = $node[\"Extract Vendor NDA\"].json.output || {};\nconst formData = $node[\"NDA Upload Form\"].json;\n\n// DEVIATION DETECTION ENGINE\nlet riskScore = 0;\nlet deviationCount = 0;\nconst modifiedClauses = [];\nconst deletedClauses = [];\nconst addedClauses = [];\nconst criticalChanges = [];\nconst highPriorityChanges = [];\nconst mediumPriorityChanges = [];\n\n// Helper function to detect significant differences\nfunction hasSignificantChange(standard, vendor) {\n  if (!vendor || vendor.trim() === '') return true; // Deleted\n  \n  const stdClean = standard.toLowerCase().replace(/\\s+/g, ' ').trim();\n  const venClean = vendor.toLowerCase().replace(/\\s+/g, ' ').trim();\n  \n  // Calculate similarity (simple word-based)\n  const stdWords = new Set(stdClean.split(' '));\n  const venWords = new Set(venClean.split(' '));\n  const intersection = new Set([...stdWords].filter(x => venWords.has(x)));\n  const similarity = intersection.size / Math.max(stdWords.size, venWords.size);\n  \n  return similarity < 0.85; // 85% threshold for significant change\n}\n\n// Check each section for deviations\nfor (const [section, standardText] of Object.entries(STANDARD_TEMPLATE)) {\n  const vendorText = vendorNDA[section] || '';\n  const clauseInfo = CRITICAL_CLAUSES[section];\n  \n  if (!vendorText || vendorText.trim() === '') {\n    // Section deleted\n    deletedClauses.push(section.replace(/_/g, ' '));\n    deviationCount++;\n    \n    if (clauseInfo) {\n      riskScore += clauseInfo.weight;\n      const changeDesc = `${section.replace(/_/g, ' ')} (DELETED)`;\n      \n      if (clauseInfo.priority === 'CRITICAL') {\n        criticalChanges.push(changeDesc);\n      } else if (clauseInfo.priority === 'HIGH') {\n        highPriorityChanges.push(changeDesc);\n      } else if (clauseInfo.priority === 'MEDIUM') {\n        mediumPriorityChanges.push(changeDesc);\n      }\n    }\n  } else if (hasSignificantChange(standardText, vendorText)) {\n    // Section modified\n    modifiedClauses.push(section.replace(/_/g, ' '));\n    deviationCount++;\n    \n    if (clauseInfo) {\n      riskScore += clauseInfo.weight;\n      const changeDesc = `${section.replace(/_/g, ' ')} (MODIFIED)`;\n      \n      if (clauseInfo.priority === 'CRITICAL') {\n        criticalChanges.push(changeDesc);\n      } else if (clauseInfo.priority === 'HIGH') {\n        highPriorityChanges.push(changeDesc);\n      } else if (clauseInfo.priority === 'MEDIUM') {\n        mediumPriorityChanges.push(changeDesc);\n      }\n    } else {\n      // Minor section modified\n      riskScore += 5;\n    }\n  }\n}\n\n// Check for additional sections\nif (vendorNDA.Additional_Sections && vendorNDA.Additional_Sections.trim() !== '') {\n  const additionalSections = vendorNDA.Additional_Sections.split('\\n').filter(s => s.trim());\n  additionalSections.forEach(section => {\n    addedClauses.push(section.trim());\n    deviationCount++;\n    riskScore += 10; // Each additional clause adds 10 points\n  });\n}\n\n// RISK LEVEL DETERMINATION\nlet riskLevel = '';\nlet approvalRecommendation = '';\nlet assignedTo = '';\nlet reviewStatus = '';\n\nif (riskScore >= 75) {\n  riskLevel = 'CRITICAL';\n  approvalRecommendation = 'BLOCK EXECUTION - Legal Review Required';\n  assignedTo = 'Senior Legal Counsel + General Counsel';\n  reviewStatus = 'URGENT REVIEW REQUIRED';\n} else if (riskScore >= 50) {\n  riskLevel = 'HIGH';\n  approvalRecommendation = 'Flag for Senior Counsel Approval';\n  assignedTo = 'Senior Legal Counsel';\n  reviewStatus = 'SENIOR REVIEW REQUIRED';\n} else if (riskScore >= 25) {\n  riskLevel = 'MEDIUM';\n  approvalRecommendation = 'Standard Review Process';\n  assignedTo = 'Legal Team';\n  reviewStatus = 'STANDARD REVIEW';\n} else {\n  riskLevel = 'LOW';\n  approvalRecommendation = 'Minor Deviations - Auto-Approve with Documentation';\n  assignedTo = 'Legal Coordinator';\n  reviewStatus = 'AUTO-APPROVED';\n}\n\n// Format output for Google Sheets\nreturn {\n  Vendor_Name: formData.Vendor_Name || 'NOT_FOUND',\n  NDA_Date: formData['NDA_Date__YYYY-MM-DD_'] || 'NOT_FOUND',\n  Template_Version: formData.Template_Version_Used || 'NOT_FOUND',\n  Deviation_Count: deviationCount,\n  Risk_Score: riskScore,\n  Risk_Level: riskLevel,\n  Modified_Clauses: modifiedClauses.join('; ') || 'None',\n  Deleted_Clauses: deletedClauses.join('; ') || 'None',\n  Added_Clauses: addedClauses.join('; ') || 'None',\n  Critical_Changes: criticalChanges.join('; ') || 'None',\n  High_Priority_Changes: highPriorityChanges.join('; ') || 'None',\n  Medium_Priority_Changes: mediumPriorityChanges.join('; ') || 'None',\n  Approval_Recommendation: approvalRecommendation,\n  Assigned_To: assignedTo,\n  Review_Status: reviewStatus,\n  Processed_Date: new Date().toISOString().split('T')[0],\n  _raw_vendor_data: vendorNDA,\n  _risk_breakdown: {\n    critical: criticalChanges.length,\n    high: highPriorityChanges.length,\n    medium: mediumPriorityChanges.length,\n    total_score: riskScore\n  }\n};"
      },
      "id": "deviation-engine-001",
      "name": "Deviation Analysis Engine",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [336, -144]
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "1TEknY4I5JU8R9SH7e2EJS3_pFYdiSteOWbCVhGys05Q",
          "mode": "list",
          "cachedResultName": "NDA Deviation Log"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Sheet1"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Vendor_Name": "={{ $json.Vendor_Name }}",
            "NDA_Date": "={{ $json.NDA_Date }}",
            "Template_Version": "={{ $json.Template_Version }}",
            "Deviation_Count": "={{ $json.Deviation_Count }}",
            "Risk_Score": "={{ $json.Risk_Score }}",
            "Risk_Level": "={{ $json.Risk_Level }}",
            "Modified_Clauses": "={{ $json.Modified_Clauses }}",
            "Deleted_Clauses": "={{ $json.Deleted_Clauses }}",
            "Added_Clauses": "={{ $json.Added_Clauses }}",
            "Critical_Changes": "={{ $json.Critical_Changes }}",
            "High_Priority_Changes": "={{ $json.High_Priority_Changes }}",
            "Medium_Priority_Changes": "={{ $json.Medium_Priority_Changes }}",
            "Approval_Recommendation": "={{ $json.Approval_Recommendation }}",
            "Assigned_To": "={{ $json.Assigned_To }}",
            "Review_Status": "={{ $json.Review_Status }}",
            "Processed_Date": "={{ $json.Processed_Date }}"
          },
          "matchingColumns": [],
          "schema": []
        },
        "options": {}
      },
      "id": "log-to-sheet-001",
      "name": "Log to Sheet",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [624, -144],
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "google-sheets-cred-001",
          "name": "Google Sheets account"
        }
      }
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "conditions": [
                  {
                    "leftValue": "={{ $json.Risk_Level }}",
                    "rightValue": "CRITICAL",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ]
              },
              "renameOutput": true,
              "outputKey": "CRITICAL"
            },
            {
              "conditions": {
                "conditions": [
                  {
                    "leftValue": "={{ $json.Risk_Level }}",
                    "rightValue": "HIGH",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ]
              },
              "renameOutput": true,
              "outputKey": "HIGH"
            },
            {
              "conditions": {
                "conditions": [
                  {
                    "leftValue": "={{ $json.Risk_Level }}",
                    "rightValue": "MEDIUM",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ]
              },
              "renameOutput": true,
              "outputKey": "MEDIUM"
            },
            {
              "conditions": {
                "conditions": [
                  {
                    "leftValue": "={{ $json.Risk_Level }}",
                    "rightValue": "LOW",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ]
              },
              "renameOutput": true,
              "outputKey": "LOW"
            }
          ]
        },
        "options": {}
      },
      "id": "alert-router-001",
      "name": "Alert Router",
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.3,
      "position": [816, -144]
    },
    {
      "parameters": {
        "jsCode": "const data = $input.first().json;\n\nreturn {\n  recipientEmail: 'legal@company.com, generalcounsel@company.com',\n  emailSubject: `🚨 CRITICAL NDA DEVIATION - ${data.Vendor_Name} - EXECUTION BLOCKED`,\n  emailBody: `URGENT: Critical deviations detected in NDA from ${data.Vendor_Name}\n\n⚠️ EXECUTION BLOCKED - IMMEDIATE LEGAL REVIEW REQUIRED ⚠️\n\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\nDEVIATION SUMMARY\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n\nVendor: ${data.Vendor_Name}\nNDA Date: ${data.NDA_Date}\nTemplate: ${data.Template_Version}\n\nRisk Score: ${data.Risk_Score}/100\nRisk Level: ${data.Risk_Level}\nTotal Deviations: ${data.Deviation_Count}\n\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\nCRITICAL CHANGES\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n${data.Critical_Changes}\n\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\nHIGH PRIORITY CHANGES\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n${data.High_Priority_Changes}\n\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\nMODIFIED CLAUSES\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n${data.Modified_Clauses}\n\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\nDELETED CLAUSES\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n${data.Deleted_Clauses}\n\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\nADDED CLAUSES\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n${data.Added_Clauses}\n\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\nRECOMMENDATION\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n${data.Approval_Recommendation}\n\nAssigned To: ${data.Assigned_To}\n\n⚠️ DO NOT PROCEED WITH EXECUTION UNTIL LEGAL REVIEW IS COMPLETE ⚠️\n\nPlease review the vendor-signed NDA immediately and provide guidance.\n\n---\nAutomatically generated by NDA Deviation Detector\nProcessed: ${data.Processed_Date}`\n};"
      },
      "id": "build-critical-email-001",
      "name": "Build Critical Alert",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [1008, -304]
    },
    {
      "parameters": {
        "jsCode": "const data = $input.first().json;\n\nreturn {\n  recipientEmail: 'legal@company.com',\n  emailSubject: `⚠️ HIGH RISK NDA Deviation - ${data.Vendor_Name} - Senior Counsel Review Required`,\n  emailBody: `High-risk deviations detected in NDA from ${data.Vendor_Name}\n\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\nDEVIATION SUMMARY\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n\nVendor: ${data.Vendor_Name}\nNDA Date: ${data.NDA_Date}\nTemplate: ${data.Template_Version}\n\nRisk Score: ${data.Risk_Score}/100\nRisk Level: ${data.Risk_Level}\nTotal Deviations: ${data.Deviation_Count}\n\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\nHIGH PRIORITY CHANGES\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n${data.High_Priority_Changes}\n\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\nMEDIUM PRIORITY CHANGES\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n${data.Medium_Priority_Changes}\n\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\nCLAUSE DETAILS\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n\nModified: ${data.Modified_Clauses}\nDeleted: ${data.Deleted_Clauses}\nAdded: ${data.Added_Clauses}\n\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\nRECOMMENDATION\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n${data.Approval_Recommendation}\n\nAssigned To: ${data.Assigned_To}\n\nSenior counsel approval required before proceeding.\n\n---\nAutomatically generated by NDA Deviation Detector\nProcessed: ${data.Processed_Date}`\n};"
      },
      "id": "build-high-email-001",
      "name": "Build High Risk Alert",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [1008, -144]
    },
    {
      "parameters": {
        "jsCode": "const data = $input.first().json;\n\nreturn {\n  recipientEmail: 'legal@company.com',\n  emailSubject: `NDA Deviation Detected - ${data.Vendor_Name} - Standard Review`,\n  emailBody: `NDA deviations detected for ${data.Vendor_Name} - Standard review process initiated.\n\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\nDEVIATION SUMMARY\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n\nVendor: ${data.Vendor_Name}\nNDA Date: ${data.NDA_Date}\nTemplate: ${data.Template_Version}\n\nRisk Score: ${data.Risk_Score}/100\nRisk Level: ${data.Risk_Level}\nTotal Deviations: ${data.Deviation_Count}\n\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\nCHANGES DETECTED\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n\nModified: ${data.Modified_Clauses}\nDeleted: ${data.Deleted_Clauses}\nAdded: ${data.Added_Clauses}\n\nMedium Priority: ${data.Medium_Priority_Changes}\n\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\nRECOMMENDATION\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n${data.Approval_Recommendation}\n\nAssigned To: ${data.Assigned_To}\n\nPlease review at your earliest convenience.\n\n---\nAutomatically generated by NDA Deviation Detector\nProcessed: ${data.Processed_Date}`\n};"
      },
      "id": "build-medium-email-001",
      "name": "Build Standard Alert",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [1008, 16]
    },
    {
      "parameters": {
        "jsCode": "const data = $input.first().json;\n\nreturn {\n  recipientEmail: 'legal-coordinator@company.com',\n  emailSubject: `✅ NDA Minor Deviations - ${data.Vendor_Name} - Auto-Approved`,\n  emailBody: `Minor deviations detected in NDA from ${data.Vendor_Name} - Auto-approved with documentation.\n\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\nDEVIATION SUMMARY\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n\nVendor: ${data.Vendor_Name}\nNDA Date: ${data.NDA_Date}\nTemplate: ${data.Template_Version}\n\nRisk Score: ${data.Risk_Score}/100\nRisk Level: ${data.Risk_Level}\nTotal Deviations: ${data.Deviation_Count}\n\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\nMINOR CHANGES\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n\nModified: ${data.Modified_Clauses}\nAdded: ${data.Added_Clauses}\n\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\nSTATUS\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n${data.Approval_Recommendation}\n\nThe NDA has been auto-approved and logged for records.\n\n---\nAutomatically generated by NDA Deviation Detector\nProcessed: ${data.Processed_Date}`\n};"
      },
      "id": "build-low-email-001",
      "name": "Build Low Risk Notification",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [1008, 176]
    },
    {
      "parameters": {
        "sendTo": "={{ $json.recipientEmail }}",
        "subject": "={{ $json.emailSubject }}",
        "message": "={{ $json.emailBody }}",
        "options": {}
      },
      "id": "send-critical-001",
      "name": "Send Critical Alert",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [1200, -304],
      "credentials": {
        "gmailOAuth2": {
          "id": "gmail-cred-001",
          "name": "Gmail account"
        }
      }
    },
    {
      "parameters": {
        "sendTo": "={{ $json.recipientEmail }}",
        "subject": "={{ $json.emailSubject }}",
        "message": "={{ $json.emailBody }}",
        "options": {}
      },
      "id": "send-high-001",
      "name": "Send High Risk Alert",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [1200, -144],
      "credentials": {
        "gmailOAuth2": {
          "id": "gmail-cred-001",
          "name": "Gmail account"
        }
      }
    },
    {
      "parameters": {
        "sendTo": "={{ $json.recipientEmail }}",
        "subject": "={{ $json.emailSubject }}",
        "message": "={{ $json.emailBody }}",
        "options": {}
      },
      "id": "send-medium-001",
      "name": "Send Standard Alert",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [1200, 16],
      "credentials": {
        "gmailOAuth2": {
          "id": "gmail-cred-001",
          "name": "Gmail account"
        }
      }
    },
    {
      "parameters": {
        "sendTo": "={{ $json.recipientEmail }}",
        "subject": "={{ $json.emailSubject }}",
        "message": "={{ $json.emailBody }}",
        "options": {}
      },
      "id": "send-low-001",
      "name": "Send Low Risk Notification",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [1200, 176],
      "credentials": {
        "gmailOAuth2": {
          "id": "gmail-cred-001",
          "name": "Gmail account"
        }
      }
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "value": "gpt-4o-mini",
          "mode": "list"
        },
        "options": {}
      },
      "id": "gpt-4o-mini-001",
      "name": "GPT-4o Mini",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.3,
      "position": [80, 48],
      "credentials": {
        "openAiApi": {
          "id": "openai-cred-001",
          "name": "OpenAi account"
        }
      }
    }
  ],
  "connections": {
    "NDA Upload Form": {
      "main": [[{"node": "Upload NDA", "type": "main", "index": 0}]]
    },
    "Upload NDA": {
      "main": [[{"node": "Wait", "type": "main", "index": 0}]]
    },
    "Wait": {
      "main": [[{"node": "Check Status", "type": "main", "index": 0}]]
    },
    "Check Status": {
      "main": [[{"node": "Router", "type": "main", "index": 0}]]
    },
    "Router": {
      "main": [
        [{"node": "Get Vendor NDA", "type": "main", "index": 0}],
        [{"node": "Wait", "type": "main", "index": 0}]
      ]
    },
    "Get Vendor NDA": {
      "main": [[{"node": "Extract Vendor NDA", "type": "main", "index": 0}]]
    },
    "Extract Vendor NDA": {
      "main": [[{"node": "Deviation Analysis Engine", "type": "main", "index": 0}]]
    },
    "Deviation Analysis Engine": {
      "main": [[{"node": "Log to Sheet", "type": "main", "index": 0}]]
    },
    "Log to Sheet": {
      "main": [[{"node": "Alert Router", "type": "main", "index": 0}]]
    },
    "Alert Router": {
      "main": [
        [{"node": "Build Critical Alert", "type": "main", "index": 0}],
        [{"node": "Build High Risk Alert", "type": "main", "index": 0}],
        [{"node": "Build Standard Alert", "type": "main", "index": 0}],
        [{"node": "Build Low Risk Notification", "type": "main", "index": 0}]
      ]
    },
    "Build Critical Alert": {
      "main": [[{"node": "Send Critical Alert", "type": "main", "index": 0}]]
    },
    "Build High Risk Alert": {
      "main": [[{"node": "Send High Risk Alert", "type": "main", "index": 0}]]
    },
    "Build Standard Alert": {
      "main": [[{"node": "Send Standard Alert", "type": "main", "index": 0}]]
    },
    "Build Low Risk Notification": {
      "main": [[{"node": "Send Low Risk Notification", "type": "main", "index": 0}]]
    },
    "GPT-4o Mini": {
      "ai_languageModel": [[{"node": "Extract Vendor NDA", "type": "ai_languageModel", "index": 0}]]
    }
  },
  "pinData": {},
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "case-60-nda-detector-v1",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "nda-deviation-detector-instance"
  },
  "id": "case60NDATool",
  "tags": []
}
